<?php
/**
 * 用户管理类
 * @author 肖小平
 *
 */
class UserAction extends BaseAction{
	//展示用户列表
    public function user_list(){
    	import('ORG.Util.Page');// 导入分页类
    	$count = M('User')->where($this->my_where())->count();//总条数
    	$Page = new Page($count,10);//每页显示10条
    	$show = $Page->show();
    	$user_arr = M('user')->where($this->my_where())->limit($Page->firstRow.','.$Page->listRows)->select();
    	$this->assign('user_arr',$user_arr);
    	$this->assign('page',$show);// 赋值分页输出
		$this->display();//输出模板
		
    }
    /**
     *重置密码
     */
    public function reset_password(){
    	$id = $_GET['id'];
    	$data['password'] = md5('123456');
    	M('User')->where("id=$id")->save($data);
    	$this->success('重置密码为123456成功','user_list');
    }
    //搜索配置
    public function my_where(){
    	$where = '';
    	$search_word = $_GET['search_word'];
    	if($search_word) {
    		$where = "(nickname like '%$search_word%') or (username like '%$search_word%') or (phone like '%$search_word%')";//按招生地区分类
    	}
    	return $where;
    }
}